package com.example.warehouse_manager.controller;

import com.example.warehouse_manager.entity.*;
import com.example.warehouse_manager.page.Page;
import com.example.warehouse_manager.service.InStoreService;
import com.example.warehouse_manager.service.StoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/instore")
public class InStoreController {

    @Autowired
    private StoreService storeService;

    @Autowired
    private InStoreService inStoreService;

    //查询所有仓库
    @RequestMapping("/store-list")
    public Result storeList(){
        List<Store> stores = storeService.queryAllStore();
        return Result.ok(stores);
    }

    //分页查询入库单
    @RequestMapping("/instore-page-list")
    public Result inStoreListPage(Page page, InStore inStore){
        page = inStoreService.queryInStorePage(page, inStore);
        return Result.ok(page);
    }

    //确认入库单
    @RequestMapping("/instore-confirm")
    public Result confirmInStore(@RequestBody InStore inStore){
        return inStoreService.inStoreConfirm(inStore);
    }

    //导出数据
    @RequestMapping("/exportTable")
    public Result exportTable(Page page, InStore inStore){
        page = inStoreService.queryInStorePage(page, inStore);
        List<?> resultList = page.getResultList();
        //响应
        return Result.ok(resultList);
    }

}
